package com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Live.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tnot.R;
import com.example.tnot.Teacher.CoursePart.CourseInternal.CourseDetailHome.Live.ItemBean.Member;

import java.util.List;

public class MemberManageAdapter extends RecyclerView.Adapter<MemberManageAdapter.ViewHolder>{
    private List<Member> memberList;
    public MemberManageAdapter(List<Member> memberList) {
        this.memberList = memberList;
    }

    @NonNull
    @Override
    public MemberManageAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        View view = inflater.inflate(R.layout.item_rv_course_live_member_manage_list, parent, false);
        return new MemberManageAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MemberManageAdapter.ViewHolder holder, int position) {
            holder.iv_avatar.setImageResource(memberList.get(position).getIv_icon());
            holder.tv_name.setText(memberList.get(position).getTv_name());
            holder.tv_role.setText(memberList.get(position).getTv_role());
    }

    @Override
    public int getItemCount() {
        return memberList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView iv_avatar;
        TextView tv_name,tv_role;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            iv_avatar = itemView.findViewById(R.id.iv_avatar);
            tv_name = itemView.findViewById(R.id.tv_name);
            tv_role = itemView.findViewById(R.id.tv_role);
        }
    }
}
